package hutech.ksv.view;

import hutech.ksv.entity.CongTyDataModel;
import hutech.ksv.entity.ThongTinCongTyEntity;
import hutech.ksv.service.DuyetThongTinTuyenDungService;

import java.io.Serializable;
import java.util.List;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Component
@Scope("session")
public class DuyetTTTDManagedBean implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private CongTyDataModel congTyDataModel;
	private List<ThongTinCongTyEntity> selectedCongTy;
	private List<ThongTinCongTyEntity> danhSachThongTinCongTy;	

	public CongTyDataModel getCongTyDataModel() {
		return congTyDataModel;
	}

	public void setCongTyDataModel(CongTyDataModel congTyDataModel) {
		this.congTyDataModel = congTyDataModel;
	}

	public List<ThongTinCongTyEntity> getSelectedCongTy() {
		return selectedCongTy;
	}

	public void setSelectedCongTy(List<ThongTinCongTyEntity> selectedCongTy) {
		this.selectedCongTy = selectedCongTy;
	}

	public List<ThongTinCongTyEntity> getDanhSachThongTinCongTy() {
		return danhSachThongTinCongTy;
	}

	public void setDanhSachThongTinCongTy(
			List<ThongTinCongTyEntity> danhSachThongTinCongTy) {
		this.danhSachThongTinCongTy = danhSachThongTinCongTy;
	}

	@Autowired
	DuyetThongTinTuyenDungService duyetTTTDService;
	
	@PostConstruct
	public void init() {
		danhSachThongTinCongTy = duyetTTTDService.getTatCaThongTinTuyenDung();
		congTyDataModel = new CongTyDataModel(danhSachThongTinCongTy);
	}
	
	public void onLoad() {
		selectedCongTy = null;
		danhSachThongTinCongTy = duyetTTTDService.getTatCaThongTinTuyenDung();
		congTyDataModel = new CongTyDataModel(danhSachThongTinCongTy);
	}
	
	public String duyetQuanAn() {
		for(ThongTinCongTyEntity thongTinCongTy : selectedCongTy) {
			duyetTTTDService.duyetTTTD(thongTinCongTy.getMaTTTD());
		}				
		return "duyetThongTinTuyenDung";
	}
}
